package hnlg.com.cn.purviewmanage.usermanage.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import hnlg.com.cn.model.UserVO;
import hnlg.com.cn.purviewmanage.usermanage.mapper.UserMapper;

@Service("UserService")
@Transactional(value="txManager",rollbackFor=Exception.class)
public class IUserServiceImpl implements IUserService {

	@Autowired UserMapper obj;
	@Override
	
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<UserVO> queryList(UserVO vo) throws Exception {
		return obj.queryList(vo);
	}

	@Override
	public UserVO queryvo(String userid) throws Exception {
		return obj.queryvo(userid);
	}

	@Override
	public boolean deleteuser(String userid) throws Exception {
		
		return obj.deleteuser(userid);
	}

	@Override
	public boolean adduser(UserVO vo) throws Exception {
		
		return obj.adduser(vo);
	}

	@Override
	public boolean updateuser(UserVO vo) throws Exception {
		
		return obj.updateuser(vo);
	}

	@Override
	public boolean useraddRole(long userid, String[] roleid) throws Exception {
		boolean flag=true;
		try{
			obj.deleteUserRole(userid);
			obj.useraddRole(userid, roleid);
		}catch(Exception e){
			flag=false;
			throw e;//有异常要抛出来让spring容器去捕捉：因为事务是套在该方法外面的。有异常spring会让事务回滚
		}
		return flag;
	}

	@Override
	public boolean deleteUserRole(long userid) throws Exception {
		
		return obj.deleteUserRole(userid);
	}

	@Override
	public List<String> queryRoleIdList(String userid) throws Exception {
		
		return obj.queryRoleIdList(userid);
	}

	@Override
	public UserVO queryUser(String username, String pwd) throws Exception {
		
		return obj.queryUser(username, pwd);
	}

	@Override
	public List queryUserModuleList(String userid, String cdid) throws Exception {
		
		return obj.queryModuleList(userid, cdid);
	}

}
